<?php 
//Luu giu trang thai loc
$v_receive_date_filter = "";
if(isset($_REQUEST['hdn_received_date_filter'])){
	$v_receive_date_filter = $_REQUEST['hdn_received_date_filter'];
} 
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter = $_REQUEST['hdn_recordtype_filter'];
} 
$v_record_id = 0;
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$v_record_id_list = "";
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_id_list = $_REQUEST['hdn_record_id_list'];
}
$v_receive_name = "";
if(isset($_REQUEST['hdn_tax_receiver'])){
	$v_receive_name = $_REQUEST['hdn_tax_receiver'];
}

$v_date_tu_cquan="";
if(isset($_REQUEST['hdn_txt_date_notify_tu_cquan'])){
	$v_date_tu_cquan=$_REQUEST['hdn_txt_date_notify_tu_cquan'];
}
$v_receiver_notify_name = '';
if(isset($_REQUEST['hdn_receiver_notify_name'])){
	$v_receiver_notify_name=$_REQUEST['hdn_receiver_notify_name'];
}


//Ket qua nhan bien lai thue tu co quan thue
$v_result_tu_cquan=CONST_LABEL_TAX_NHAN_BLAI_TU_CQUAN;
$v_result_tu_cquan = $v_result_tu_cquan .':&nbsp;'.$v_receiver_notify_name;
//Ket qua thong bao thue cho cong dan
$v_result = "";
if(isset($_REQUEST['hdn_txt_result'])){
	$v_result = $_REQUEST['hdn_txt_result'];
}

if($v_receive_name!=""){
	$v_result=$v_result.",".$v_receive_name;
}

if(_is_sqlserver()){
	if($code_notify=="1010"){
		$sql = " Exec Onegate_RecordHandoverUpdate_NhanTB_Thue_Tu_Cquan ";
		$sql = $sql . " '" .  $v_record_id_list . "'";
		$sql = $sql . "," . $v_staff_id ;
		$sql = $sql . ",'" . _ddmmyyyy_to_yyyymmdd($v_date_tu_cquan) . "'" ;
		$sql = $sql . "," . $_ISA_AUTOMATIC_UPDATE_WORK_LIST;
		$sql = $sql . ",'" . $v_result_tu_cquan."'";
		$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
		$rs = $ado_conn->GetRow($sql); 
		$v_error = _replace_bad_char(trim($rs['RET_ERROR']));		
	/*}
	//Cap nhat ho so
	if($code_notify=="1010"){*/
		$sql = " Exec Onegate_RecordHandoverUpdate_Tax ";
	}else{
		$sql = " Exec Onegate_RecordHandoverUpdate_Punish ";
	}
	$sql = $sql . " '" .  $v_record_id_list . "'";
	$sql = $sql . "," . $v_staff_id ;
	$sql = $sql . ",'" . _ddmmyyyy_to_yyyymmdd($v_receive_date_filter) . "'" ;
	$sql = $sql . "," . $_ISA_AUTOMATIC_UPDATE_WORK_LIST;
	$sql = $sql . ",'" . $v_result."'";
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back">
	<?php if($code_notify=="1010"){?>
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD_NOTIFY_TAX">
	<?php }else{?>
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD_NOTIFY_PHAT">
	<?php }?>
	<input type="hidden" name="hdn_record_id" value="<?php echo $v_record_id;?>">
	<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
	<input type="hidden" name="hdn_received_date_filter" value="<?php echo $v_receive_date_filter; ?>">
	<input type="hidden" name="hdn_current_item_id" value="<?php echo $v_record_id;?>">
</form>
<Script language="javascript">
	document.forms(0).submit();
</Script>